import axios from '@/libs/api.request'

export const getRouterReq = (access) => {
  let routers = axios.request({
    url: 'get_router',
    params: {
      access
    },
    method: 'get'
  })
  console.log(routers)
  let components = {}
  for (let router of routers) {
    if (typeof router.component === 'string') {
      if (typeof components[router.component] === 'undefined') {
        components[router.component] = () => import('@/components/' + router.component)
      }
      router.component = components[router.component]
    }
  }
  return routers
}
